#ifndef __DATABASE_UPDATE_EVENT_HPP__
#define __DATABASE_UPDATE_EVENT_HPP__


#ifdef ENABLE_DB_JUDGE

#include "base_event.hpp"

namespace run_code_event_space {

struct database_update_event : base_event<database_update_event>  {
    template <class U>
    ProcessStatus execute_impl(run_code_context_t<U>& context);
};

template <class U>
ProcessStatus database_update_event::execute_impl(run_code_context_t<U>& context) {
    if constexpr (contains_v<U, DatabaseModifyJudge, DatabaseSelectJudge>) {
        return general_execution_strategy::database_update(&context.judge_type.conn,
                                                                    context.judge_type.database_name, 
                                                                    context.judge_type.createTableFile,
                                                                    context.params.spjCachePath
                                                                    );
    }
    return ProcessStatus{ .result = RUN_FAIL, .error = "no support"};
}
}

#endif

#endif /* __DATABASE_UPDATE_EVENT_HPP__ */
